package com.lgit.Model4.hw05;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class ClientThread implements Runnable {
    private Socket s;

    public ClientThread(Socket s) {
        this.s = s;
    }

    @Override
    public void run() {
        BufferedReader br = null;
        try {
            while (true){
                br = new BufferedReader(new InputStreamReader(s.getInputStream()));//获取socket输入流
                String str = br.readLine();
                if ((str) != null) {
                    System.out.println(str);
                }
                if("bye".equals(str)){
                    s.close();
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
